<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp_lib/init.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>文章管理</title>
<jsp:include page="/WEB-INF/jsp/common/common.jsp" />
<jsp:include page="/WEB-INF/jsp_lib/extjs.jsp" />
<jsp:include page="/WEB-INF/jsp_lib/extjs/UMedit.jsp" />

<script type="text/javascript">
	var comboxStore;

	//设置ComboBox列表数据源参数
	comboxStore = Ext.create('Ext.data.Store', {
		fields : [ 'name', 'kid' ],
		remoteSort : true,
		autoLoad : true,
		pageSize : 20,
		sorters : {
			property : 'name',
			direction : 'ASC'
		},
		proxy : {
			type : "ajax",
			url : "${path}/cp/xyk/bank/list_data.htm",
			reader : {
				type : 'json',
				rootProperty : 'list',
				totalProperty : 'page.rowTotal'
			}
		}
	});
</script>

<jsp:include page="add.jsp" />
<jsp:include page="edit.jsp" />

<script type="text/javascript">
	var dataStore;

	Ext.onReady(function() {

		dataStore = Ext.create('Ext.data.Store', {
			fields : [ 'kid', 'status', 'created'],
			remoteSort : true,
			autoLoad : true,
			pageSize : 20,
			proxy : {
				type : "ajax",
				url : "list_data.htm",
				reader : {
					type : 'json',
					rootProperty : 'list',
					totalProperty : 'page.rowTotal'
				}
			},
			listeners : {
				'beforeload' : function(store, op, options) {
					var params = searchFormPanel.getForm().getValues();
					Ext.apply(dataStore.proxy.extraParams, params);
				}
			}
		}); //#dataStore

		var searchFormPanel = Ext.create('Ext.form.Panel', {
			frame : true,
			title : "搜索条件",
			style : {
				marginBottom : '5px'
			},
			buttonAlign : "center",
			collapsible : true,
			defaultType : "textfield",
			items : [ {
				xtype : "container",
				layout : "column",
				items : [ {
					xtype : "textfield",
					fieldLabel : "标题",
					labelStyle : "text-align:right;",
					name : "srh_name",
					id : "srh_name"
				} ,{
					xtype : "textfield",
					name : "srh_cate",
					value:'${cate}',
					hidden : true
				}]
			} ],
			buttons : [ {
				text : "搜索",
				icon : jcapp.getIcon("magnifier.png"),
				handler : function() {
					dataStore.load({
					//params:params()
					});
					dataStore.sync();
				}
			}, {
				text : "重置",
				icon : jcapp.getIcon("arrow_refresh.png"),
				handler : function() {
					this.up('form').getForm().reset();
				}
			} ]
		}); //#searchFormPanel

		var listGridPanel = Ext.create('Ext.grid.Panel', {
			title : '文章列表',
			tbar : [ {
				text : '新增',
				xtype : 'button',
				icon : jcapp.getIcon("add.png"),
				handler : function() {
					myAdd();
				}
			} ],
			dockedItems : [ {
				xtype : 'pagingtoolbar',
				store : dataStore, // same store GridPanel is using
				dock : 'bottom',
				displayInfo : true
			} ],
			store : dataStore,
			columns : [
					{
						text : '标题',
						dataIndex : 'title',
						flex : 1
					},
					{
						text : '银行',
						dataIndex : 'bank_name',
						flex : 1
					},
					{
						xtype : "actioncolumn",
						align : "center",
						text : '编辑',
						items : [ {
							xtype : 'button',
							tooltip : '编辑',
							icon : jcapp.getIcon("application_form_edit.png"),
							handler : function(grid, rowIndex, colIndex) {
								var rec = grid.getStore().getAt(rowIndex);
								//alert("编辑 " + rec.get('kid'));
								myEdit(rec.get('kid'));
							}
						}]

					},{
						xtype : "actioncolumn",
						align : "center",
						text : '删除',
						items : [ {
							xtype : 'button',
							tooltip : '删除',
							icon : jcapp.getIcon("cross.png"),
							handler : function(grid, rowIndex, colIndex) {
								var rec = grid.getStore().getAt(rowIndex);
								myDel(rec.get('kid'));
							}
						} ]

					} ]
		}); //#listGridPanel

		searchFormPanel.render(Ext.getBody());
		listGridPanel.render(Ext.getBody());

	});

	function myDel(kid) {
		Ext.Msg.confirm("提示:", "确定删除选定的记录?", function(e) {
			if (e == "yes") {
				Ext.Ajax.request({
					url : "del.htm?kid=" + kid,
					success : function(response) {
						var json = Ext.util.JSON.decode(response.responseText);
						Ext.Msg.alert("提示", json.tip.msg);
						dataStore.load();
					},
					failure : function(response) {
						Ext.Msg.alert("提示", "操作失败!");
					}
				});
			}//#if
		});
	}//#myDel
</script>
</head>
<body>

</body>
</html>
